<?php

namespace Article;

use C\L\Controller;

class InfoController extends Controller
{

    function demoAction(){
        $this->success(['msg'=>'I am  demo']);
    }

    protected function init()
    {
        $this->service = $this->s_article;
        $this->searchLimit = 100;

        $this->showKeys = [
        'title', 'code'
        ];

        $this->pubSearchKeys = [
        'cat'
        ];
        $this->hideKeys = [
        'is_delete'
        ];
    }

    public function beforeSearch()
    {

        $this->params['order'] = 'sort desc';
        $this->params['page_num'] = 100;
        $this->params['data']['cat'] = 'about';
        $this->params['data']['is_disable'] = 'Y';
        return true;
    }

    public function detailAction()
    {
        $code = $this->getValue('code', true, 'string');
        $article = $this->s_article->search(['code' => $code, 'is_disable' => 'Y'], [], ['title', 'content']);
        if ($article) {
            $this->success($article);
        }

        $this->error('内容不存在');
    }
}
